package com.mjk.manager.usercenter.depart;

import com.mjk.common.base.error.BeeError;
import com.mjk.common.base.response.BeeResponse;
import com.mjk.common.base.work.BaseWork;
import com.mjk.common.base.work.annotation.BeeWork;
import com.mjk.common.core.jdbc.service.plus.idbservice.BeeDBService;
import com.mjk.common.core.jdbc.service.plus.wrap.BeeQueryWrapper;
import com.mjk.manager.amis.core.model.SysDept;
import com.mjk.manager.usercenter.depart.dto.DepartDto;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * 部门
 */
@BeeWork(work = "scdepart")
public class ScDepartWork extends BaseWork {
    @Autowired
    private BeeDBService beeDBService;

    /**
     * 获取部门树
     *
     * @param dto
     * @return
     */
    public BeeResponse getScDepartTree(DepartDto dto) {
        BeeQueryWrapper wrapper = new BeeQueryWrapper(new SysDept());
        List<SysDept> departs = beeDBService.findManyByWrapper(wrapper);
        return BeeError.BEE_SUC.tranceError(getTreeList(departs, "0", "departId", "parentId", "children", false));
    }
}
